package com.mrjy.maintain.bo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mrjy.common.dto.WeUIPickerDto;
import com.mrjy.maintain.dao.IStageInfoDao;

@Service("stageInfoBo")
public class StageInfoBo implements IStageInfoBo{

	@Resource
	private IStageInfoDao stageInfoDao;

	@Override
	public Object txInsert(Object object) {
		return stageInfoDao.insert(object);
	}

	@Override
	public Object txDeleteByIds(int[] ids) {
		try {
			return stageInfoDao.deleteByIds(ids);
		} catch (Exception e) {
			return 0;
		}
	}

	@Override
	public Object updateDisableFlag(Object object) {
		return stageInfoDao.updateDisableFlag(object);
	}

	@Override
	public Object txUpdateById(Object object) {
		return stageInfoDao.updateById(object);
	}

	@Override
	public Object queryById(int id) {
		return stageInfoDao.queryById(id);
	}

	@Override
	public Object queryList(Object object) {
		return stageInfoDao.queryList(object);
	}

	@Override
	public Object queryPage(Object object) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("total", stageInfoDao.countList(object));
		map.put("rows", stageInfoDao.queryList(object));
		return map;
	}

	@Override
	public Object selectListForWeUIPicker() {
		Map<String,Object> map = new HashMap<String, Object>();
		List<WeUIPickerDto> list = stageInfoDao.selectListForWeUIPicker();
		if (null != list && list.size() > 0) {
			Map<String, Object> dicMap = new HashMap<String, Object>();
			for(WeUIPickerDto dto : list){
				dicMap.put(dto.getValue(), dto.getLabel());
			}
			map.put("err_code", 0);
			map.put("err_msg", "查询成功");
			map.put("stageInfoList", list);
			map.put("dicMap", dicMap);
		}else {
			map.put("err_code", 1);
			map.put("err_msg", "没有数据");
		}
		return map;
	}
	
}
